<?php

namespace app\wechat\controllers;

use cm\util\Util;
use Yii;
use yii\base\Controller;

class CommonController extends Controller
{
    public function actionChecksign()
    {
        $signature = $_GET["signature"];
        $timestamp = $_GET["timestamp"];
        $nonce = $_GET["nonce"];

        $token = "e1d7a00857da8486dad6cc78b42f3216";
        $tmpArr = array($token, $timestamp, $nonce);
        sort($tmpArr, SORT_STRING);
        $tmpStr = implode($tmpArr);
        $tmpStr = sha1($tmpStr);

        Util::logInfo("signature", [$tmpStr, $signature]);
        if ($tmpStr == $signature) {
            return $_GET['echostr'];
        } else {
            return false;
        }
    }
}